/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Screen;

import ClassFrame.InputKey;
import ClassFrame.Map;
import ClassFrame.Resource;
import GamePlay.CanvasGame;
import javax.microedition.lcdui.Graphics;

/**
 *
 * @author QuyetNM1
 */
public class Welcome2 extends IScreen {

    private long startTime;
    private long currTime;

    public Welcome2(CanvasGame _canvas) {
        super(_canvas);
        startTime = System.currentTimeMillis();
        currTime = startTime;

    }
    public int countImage = 0;

    public void initComponents() {
    }

    public void load_screen() {
        canvas.getResource().loadArray(Resource.welcomeArrayImages);
    }

    public void un_load_screen() {
        canvas.getResource().unLoadArray(Resource.welcomeArrayImages);
    }

    public void keyEvent(int keycode, int event) {
        if (event == InputKey.KEY_EVENT_DOWN) {
            if (countImage < 1) {
                countImage++;
            } else {
                Game.score = 0;
                Game.scoreRound1 = 0;
                Game.scoreRound2 = 0;
                Game.scoreRound3 = 0;
                Map.round = Map.ROUND1;
                canvas.setScreen(new Rule(canvas));
            }
        }
    }

    public void pointerEvent(int x, int y, int event) {
        switch (event) {
            case InputKey.POINTER_EVENT_DOWN:
                if (countImage < 1) {
                    countImage++;
                } else {
                    Game.score = 0;
                    Game.scoreRound1 = 0;
                    Game.scoreRound2 = 0;
                    Game.scoreRound3 = 0;
                    Map.round = Map.ROUND1;
                    canvas.setScreen(new Rule(canvas));
                }
                break;
            case InputKey.POINTER_EVENT_UP:
                break;
        }
    }

    public void update() {
    }
    
    private int count = 0;
    
    public void paint(Graphics g) {
        count++;
        if (countImage < 1) {
            canvas.getImage().drawImage(g, canvas, Resource.IMG_WELCOME5, 0, 0);
            if (count % 16 < 8) {
                canvas.getImage().drawImage(g, canvas, Resource.IMG_CONTINUE, 0, 260);
            }
        } else {
            canvas.getImage().drawImage(g, canvas, Resource.IMG_WELCOME4, 0, 0);
            if (count % 16 < 8) {
                canvas.getImage().drawImage(g, canvas, Resource.IMG_CONTINUE, 0, 260);
            }
        }
    }
}
